package vo
{
	[Bindable]
	public class EnglishWeight
	{
		public var lb:Number;
		public var oz:Number;
		
		public function EnglishWeight(value:Number) {
			// given a value in metric unit, contruct a English unit
			if (isNaN(value) || value == 0) return;
			lb = Math.floor(value / 0.45359237);
			var t:Number = (value / 0.45359237 - lb ) * 16;
			if ((t - Math.floor(t)) > 0.5) {
				oz = Math.ceil(t);
			} else {
				oz = Math.floor(t);
			}
			if (oz == 16) {
				lb = lb + 1;
				oz = 0;
			}
		}

		public function toString():String {
			var result:String = lb + " lb "; 
			if (oz > 0) {
				result = result + oz + " oz";
			}
			return  result ;
		}
	}
}